﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FilStartUps.DAL;

namespace FilStartUps.Controls
{
    public partial class FilStartUps_ShowThread : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int id = Convert.ToInt32(Request.QueryString["t"].Trim());
                ShowThread(id);
            }
        }

        private void ShowThread(int forumid)
        {
            using (FilStartUpsEntities db_connect = new FilStartUpsEntities())
            {
                var show = db_connect.ForumThreads.Where(p => p.forumthreadidPK.Equals(forumid)).SingleOrDefault();
                //dlforumdisplay.DataSource = show;
                //dlforumdisplay.DataBind();

                //var showthread = (from ft in db_connect.ForumThreads
                //                  join fr in db_connect.ForumReplies
                //                     on ft.forumthreadidPK equals fr.forumthreadidFK
                //                  where ft.forumthreadidPK.Equals(forumid)
                //                  select new
                //                  {
                //                      memberidFK = ft.memberidFK,
                //                      forumtitle = ft.forumtitle,
                //                      forumdescription= ft.forumdescription,
                //                      ForumReply = fr.replydescription,
                //                      memberidFK_ = fr.memberidFK,
                                     
                //                  }).ToList();

                //dlforumdisplay.DataSource = showthread;
                //dlforumdisplay.DataBind();
                img_Profile.ImageUrl = "../FilStartUps.ashx?id=" + show.memberidFK + "&cat=" + 1;
                lbforumtitle.Text = show.forumtitle;
                ltforumdesc.Text = show.forumdescription;
            }
        }

        protected void lbpostreply_Click(object sender, EventArgs e)
        {

            Response.Redirect("~/ThreadReply.aspx?t=" + Convert.ToInt32(Request.QueryString["t"].Trim()));
        }
    }
}